package com.shyb.lingxian.mine.fragment;

import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.shyb.lingxian.R;
import com.shyb.lingxian.Util.ToastUtil;
import com.shyb.lingxian.base.BaseFragment;
import com.shyb.lingxian.mine.activity.AddressMangerActivity;
import com.shyb.lingxian.mine.activity.AfterSalesWebVActivity;
import com.shyb.lingxian.mine.activity.AllOrdersActivity;
import com.shyb.lingxian.mine.activity.LoginActivity;
import com.shyb.lingxian.mine.activity.SetActivity;
import com.shyb.lingxian.mine.presenter.MineFragmentPresenter;
import com.shyb.lingxian.mine.view.MineFragmentView;

/**
 * Created by gs on 2018/3/23.
 */

public class MineFragment extends BaseFragment<MineFragmentPresenter> implements MineFragmentView ,View.OnClickListener{

    private View fragment_mine;
    private Button MF_login;
    private ImageView MF_edit;
    private RelativeLayout MF_all_order;
    private LinearLayout MF_daifukuan;
    private LinearLayout MF_daifahuo;
    private LinearLayout MF_daishouhuo;
    private LinearLayout MF_tuihuo;
    private LinearLayout MF_manage_address;
    private LinearLayout MF_contact_service;
    private LinearLayout MF_after_sales;
    private LinearLayout MF_set;

    @Override
    protected MineFragmentPresenter initPresenter() {
        return new MineFragmentPresenter(this);
    }

    @Override
    protected void initialize() {
        MF_login = (Button) fragment_mine.findViewById(R.id.MF_login);
        MF_edit = (ImageView) fragment_mine.findViewById(R.id.MF_edit); //修改昵称
        MF_all_order = (RelativeLayout) fragment_mine.findViewById(R.id.MF_all_order);
        MF_daifukuan = (LinearLayout) fragment_mine.findViewById(R.id.MF_daifukuan);
        MF_daifahuo = (LinearLayout) fragment_mine.findViewById(R.id.MF_daifahuo);
        MF_daishouhuo = (LinearLayout) fragment_mine.findViewById(R.id.MF_daishouhuo);
        MF_tuihuo = (LinearLayout) fragment_mine.findViewById(R.id.MF_tuihuo);
        MF_manage_address = (LinearLayout) fragment_mine.findViewById(R.id.MF_manage_address);
        MF_contact_service = (LinearLayout) fragment_mine.findViewById(R.id.MF_contact_service);
        MF_after_sales = (LinearLayout) fragment_mine.findViewById(R.id.MF_after_sales);
        MF_set = (LinearLayout) fragment_mine.findViewById(R.id.MF_set);


        MF_login.setOnClickListener(this);
        MF_edit.setOnClickListener(this);
        MF_all_order.setOnClickListener(this);
        MF_daifukuan.setOnClickListener(this);
        MF_daifahuo.setOnClickListener(this);
        MF_daishouhuo.setOnClickListener(this);
        MF_tuihuo.setOnClickListener(this);
        MF_manage_address.setOnClickListener(this);
        MF_contact_service.setOnClickListener(this);
        MF_after_sales.setOnClickListener(this);
        MF_set.setOnClickListener(this);

    }

    @Override
    public View initView(LayoutInflater inflater) {
        fragment_mine = inflater.inflate(R.layout.fragment_my, null);
        return fragment_mine;
    }

    @Override
    public void onError(String message) {
        ToastUtil.showToast(getContext(),message);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.MF_login:         //登录
                startActivity(new Intent(getActivity(), LoginActivity.class));

                break;

            case R.id.MF_edit:   //修改昵称

                break;

            case R.id.MF_all_order:         //查看全部订单
                startActivity(new Intent(getContext(),AllOrdersActivity.class));

                break;

            case R.id.MF_daifukuan:         //待付款


                break;

            case R.id.MF_daifahuo:         //待发货


                break;

            case R.id.MF_daishouhuo:         //待收货


                break;

            case R.id.MF_tuihuo:         //退货和售后


                break;

            case R.id.MF_manage_address:         //收货地址管理
                startActivity(new Intent(getActivity(),AddressMangerActivity.class));

                break;

            case R.id.MF_contact_service:         //联系客服
                Intent intent3 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "4001106111"));
                intent3.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent3);

                break;

            case R.id.MF_after_sales:         //售后服务
                startActivity(new Intent(getActivity(), AfterSalesWebVActivity.class));

                break;

            case R.id.MF_set:         //设置
                startActivity(new Intent(getActivity(),SetActivity.class));

                break;
        }
    }
}
